﻿using HK.Core.GUIEx.Attribute;
using HK.Core.GUIEx.Protocol.Attribute;
using HK.Core.Serializable.Protocol.Attribute;
using HK.Core.Utils;

namespace HK.Core.Serializable.Attribute
{
    /// <summary>
    /// Attribute - 校验码
    /// </summary>
    public class CheckCodeAttribute : GUIAttribute, ICheckCodeAttribute
    {
        
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="iCaption">标题</param>
        /// <param name="iOptions">选项</param>
        public CheckCodeAttribute(string iCaption, int iOptions = (int)GUIOperateOptions.CheckCode) :
            this(iCaption, CheckMode.Md5, iOptions) { }
        
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="iCaption">标题</param>
        /// <param name="iMode">校验码</param>
        /// <param name="iOptions">选项</param>
        public CheckCodeAttribute(string iCaption, CheckMode iMode, int iOptions = (int)GUIOperateOptions.CheckCode) :
            this(iCaption, iMode, null, iOptions) { }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="iCaption">标题</param>
        /// <param name="iMode">校验码</param>
        /// <param name="iTips">提示</param>
        /// <param name="iOptions">选项</param>
        public CheckCodeAttribute(string iCaption, CheckMode iMode, string iTips, int iOptions = (int)GUIOperateOptions.CheckCode) :
            this(iCaption, iMode, null, iTips, iOptions) { }
        
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="iCaption">标题</param>
        /// <param name="iMode">校验码</param>
        /// <param name="iIcon">Icon</param>
        /// <param name="iTips">提示</param>
        /// <param name="iOptions">选项</param>
        public CheckCodeAttribute(string iCaption, CheckMode iMode, string iIcon, string iTips, int iOptions = (int)GUIOperateOptions.CheckCode)
        {
            Caption = iCaption;
            Mode = iMode;
            Icon = iIcon;
            Tips = iTips;
            Options = iOptions;
        }
        
        /// <summary>
        /// 保护构造函数
        /// </summary>
        protected CheckCodeAttribute() : base() {}
        
        /// <summary>
        /// 校验码
        /// </summary>
        public CheckMode Mode { get; private set; } = CheckMode.Md5;
    }
}